<?php $this->load->view('common/head');?>
<script src="/public/js/echarts.min.js"></script>
<?php $this->load->view('common/navbar');?>
<h2 class="fs24 mb20 mt10" style="text-align: center;"><?=$proData['proName']?></h2>
<div class="timetips2">
<p>所属双月：<?=$proData['timeUnitStr']?> </p>
<p>项目类型：<?=$proData['proTypeName']?> </p>
<p>截至提交时间：<?=date("Y-m-d H:i:s", $proData['endTime'])?></p>
</div>

<div class="panel panel-default">
  <div class="panel-heading"><h3>反馈有效率</h3></div>
  <div class="panel-body">
    <div class="col-md-4">
      <table class="table table-bordered table-condensed text-center" style="width: 400px;">
      <thead>
        <tr class="active">
          <th class="text-center">反馈数量</th>
          <th class="text-center">反馈有效</th>
          <th class="text-center">反馈无效</th>
        </tr>
      </thead>
      <tbody>
      <tr align="center">
          <td><?=$reportData['validCount']+$reportData['invalidCount']?></td>
          <td><?=$reportData['validCount']?></td>
          <td><?=$reportData['invalidCount']?></td>
      </tr>
      </tbody>
    </table>
    </div>
    <div id="projectCount" style="width: 300px;height:300px;clear: both;"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var projectCountChart = echarts.init(document.getElementById('projectCount'));

        // 指定图表的配置项和数据
        var option = {
            title : {
                text: '反馈有效率',
                x:'center'
            },
            tooltip : {
                trigger: 'item',
                formatter: "{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: ['反馈有效','反馈无效']
            },
            series : [
                {
                    name: '反馈有效率',
                    type: 'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
                        {value:<?=(int)$reportData['validCount']?>, name:'反馈有效'},
                        {value:<?=(int)$reportData['invalidCount']?>, name:'反馈无效'},
                    ],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        projectCountChart.setOption(option);
    </script>
  </div>
</div>
<?php foreach ($actList as $actK => $actV) {?>
<div class="partone mt10"></div>
<div class="panel panel-default feedbackpart">
  <!-- Default panel contents -->
  <div class="panel-heading"><h3><?=$actV['actTitle']?></h3></div>
  <div class="panel-body">
    <p><?=$actV['actDesc']?></p>
  </div>
  <div class="panel-body">
  <?php
  foreach ($actV['itemList'] as $itemK => $itemV) {
    $countData = isset($reportData['countDetail'][$itemK]) ? $reportData['countDetail'][$itemK] : array();
  ?>
  <div class="partone mt10"></div>
    <div class="form-group" style="margin-bottom: 15px;clear: both;">
    <span for="inputHelpBlock" style="line-height: 30px;font-size: 14px;"><?=$itemV['itemTitle']?></span>
    <p id="helpBlock<?=$itemId?>"  style="line-height: 30px;font-size: 14px;" class="help-block"><?=$itemV['itemDesc']?></p>
      <?php if (in_array($itemV['type'], array(1,6,7)))://饼图（纯文本、图片、附件题） ?>
          <div class="col-md-4">
          <table class="table table-bordered table-condensed text-center">
          <thead>
            <tr class="active">
              <th class="text-center">反馈合格</th>
              <th class="text-center">反馈不合格</th>
              <th class="text-center">反馈其他</th>
              <th class="text-center">合格率</th>
            </tr>
          </thead>
          <tbody>
          <tr>
              <td><?=isset($countData['auditRsCount'][1]) ? $countData['auditRsCount'][1] : 0?></td>
              <td><?=isset($countData['auditRsCount'][2]) ? $countData['auditRsCount'][2] : 0?></td>
              <td><?=isset($countData['auditRsCount'][-1]) ? $countData['auditRsCount'][-1] : 0?></td>
              <td>
              <?php
              $total = array_sum((array)$countData['auditRsCount']);
              $passRate = $total > 0 ? round((float)$countData['auditRsCount'][1]/$total, 4) : 0;
              echo $passRate > 0 ? $passRate*100 . '%' : 0;
              ?>
              </td>
          </tr>
          </tbody>
        </table>
        </div>
        <div id="itemCount<?=$itemK?>" style="width: 600px;height:300px;clear: both;"></div>
        <script type="text/javascript">
            // 基于准备好的dom，初始化echarts实例
            var item<?=$itemK?>CountChart = echarts.init(document.getElementById('itemCount<?=$itemK?>'));

            // 指定图表的配置项和数据
            var item<?=$itemK?>option = {
                title : {
                    text: '<?=$itemV['itemTitle']?>',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: "{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: ['反馈合格','反馈不合格','其他']
                },
                series : [
                    {
                        name: '反馈合格率',
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '60%'],
                        data:[
                            {value:<?=isset($countData['auditRsCount'][1]) ? (int)$countData['auditRsCount'][1] : 0?>, name:'反馈合格'},
                            {value:<?=isset($countData['auditRsCount'][2]) ? (int)$countData['auditRsCount'][2] : 0?>, name:'反馈不合格'},
                            {value:<?=isset($countData['auditRsCount'][-1]) ? (int)$countData['auditRsCount'][-1] : 0?>, name:'其他'},
                        ],
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            item<?=$itemK?>CountChart.setOption(item<?=$itemK?>option);
        </script>
      <?php elseif(in_array($itemV['type'], array(2)))://总分平均分（数值题） ?>
        <div class="col-md-4">
          <table class="table table-bordered table-condensed text-center">
          <thead>
            <tr class="active">
              <th class="text-center">总计</th>
              <th class="text-center">合格数量</th>
              <th class="text-center">平均值</th>
            </tr>
          </thead>
          <tbody>
          <tr>
              <?php
              $totalScore = isset($countData['totalScore']) ? $countData['totalScore'] : 0;//总分
              $passCount = isset($countData['auditRsCount'][1]) ? $countData['auditRsCount'][1] : 0;//合格数量
              $aveScore = $passCount > 0 ? round((float)$totalScore/$passCount, 2) : 0;//平均分
              ?>
              <td><?=$totalScore?></td>
              <td><?=$passCount?></td>
              <td><?=$aveScore?></td>
          </tr>
          </tbody>
        </table>
        </div>
      <?php elseif(in_array($itemV['type'], array(3,4)))://选项统计（单选、多选题） ?>
        <div class="col-md-4">
          <table class="table table-bordered table-condensed text-center">
          <thead>
            <tr class="active">
              <th class="text-center">选项</th>
              <th class="text-center">小计</th>
              <th class="text-center">比例</th>
            </tr>
          </thead>
          <tbody>
          <?php foreach ((array)$itemV['otherData']['options'] as $k => $v): ?>
          <tr>
              <?php
              $optCount = isset($countData['optionsCount'][$k]) ? $countData['optionsCount'][$k] : 0;
              $sum = array_sum((array)$countData['optionsCount']);
              $rate = $sum > 0 ? round($optCount/$sum, 4) : 0;
              ?>
              <td><?=$v?></td>
              <td><?=$optCount?></td>
              <td>
                <div class="progress" style="width: 200px;">
                  <div class="progress-bar" role="progressbar" aria-valuenow="<?=$rate*100?>" aria-valuemin="0" aria-valuemax="100" style="width: <?=$rate*100?>%;"><?=$rate*100?>%</div>
                </div>
              </td>
          </tr>
          <?php endforeach ?>
          </tbody>
        </table>
        </div>
      <?php elseif(in_array($itemV['type'], array(5)))://散列图（时间题） ?>
        <div id="itemCount<?=$itemK?>" style="width: 600px;height:300px;clear: both;"></div>
          <script type="text/javascript">
            // 基于准备好的dom，初始化echarts实例
            var item<?=$itemK?>CountChart = echarts.init(document.getElementById('itemCount<?=$itemK?>'));
            <?php
            $timeCount = isset($countData['timeCount']) ? $countData['timeCount'] : array();
            //ksort($timeCount);
            ?>
            var item<?=$itemK?>option = {
                title : {
                    text: '<?=$itemV['itemTitle']?>',
                    subtext: '<?=$itemV['itemDesc']?>'
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                tooltip : {
                    trigger: 'axis',
                    showDelay : 0,
                    position:'right',
                    formatter : function (params) {
                        if (params.value.length > 1) {
                            return new Date(params.value[1]*1000).format("yyyy-MM-dd") + ' , 专营店序号:' + params.value[0];
                            //return params.value[0];
                        }
                        else {
                            return params.seriesName + ' :<br/>'
                               + params.name + ' : '
                               + params.value;
                        }
                    },
                    backgroundColor:'#b10505',
                    axisPointer:{
                        show: true,
                        type : 'cross',
                        lineStyle: {
                            type : 'dashed',
                            width : 1
                        }
                    }
                },
                legend: {
                    data: ['时间点统计'],
                    left: 'right'
                },
                xAxis : [
                    {
                        type : 'value',
                        scale:true,
                        axisLabel : {
                            formatter: '{value}'
                        },
                        splitLine: {
                            lineStyle: {
                                type: 'dashed'
                            }
                        }
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        scale:true,
                        axisLabel : {
                            formatter: function (value, index) {
                                return new Date(value*1000).format("yyyy-MM-dd");
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                type: 'dashed'
                            }
                        }
                    }
                ],
                series : [
                    {
                        name:'时间点统计',
                        type:'scatter',
                        data: [
                            <?php foreach ($timeCount as $key => $value){
                              echo '['.$key.','.strtotime($value).'],';
                            }?>
                        ],
                        /*markPoint : {
                            data : [
                                {valueIndex:0,type : 'max', name: '最大值'},
                                {valueIndex:0,type : 'min', name: '最小值'}
                            ]
                        },
                        markLine : {
                            data : [
                                {valueIndex:0,type : 'average', name: '平均值'}
                            ]
                        }*/
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            item<?=$itemK?>CountChart.setOption(item<?=$itemK?>option);
        </script>
      <?php endif ?>
    </div>
  <?php } ?>
   </div>
</div>
<?php } ?>
<div class="form-group text-center">
	<button type="button" class="btn btn-primary" onclick="window.location.href='<?=$breadcrumb[count($breadcrumb)-2]['url']?>'">返回</button>
</div>
<?php $this->load->view('common/foot');?>